<?php

/*****************连接数据库******************/
$servername = "localhost";
$username = "root";
// 创建连接
$conn = new mysqli('localhost', 'root','');
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
} 


/****************************************获取用户信息********************************************/
$id=$_POST["id"];
$password_1=$_POST["password"];//加密前密码
$password=strrev($_POST["password"]);//加密后密码

/****************************************创建类*************************************************/
class user{
	public $id;
	public $password_1;
	public $password;
/***************************************构造函数***********************************************/	

	function __construct($i,$p_1,$p)
	{
		$this-> id = $i;
		$this-> password_1 = $p_1;
		$this-> password = $p;
	}
/*****************************************显示信息*********************************/
	function display() 
		{
			echo "账户：".$this-> id."<br>";
			echo "密码：".$this-> password_1."<br>";
		}


/*****************************************登录验证*********************************/
	 function check_out() 
		{
		
		$check_query =  mysql_query("select * from information where username='$id' and password='$password'");
		
		if ($result =  mysql_fetch_array($check_query))
		{
			echo "登录成功<br>";
		}
		else
		{
			 exit('登录失败！点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');

		}
	}
	
}


$date=new user("$id","$password_1","$password");
$date ->display();
$date ->check_out();
?>